package com.ruoyi.app.W.controller;

import com.ruoyi.app.W.service.FileService;
import com.ruoyi.framework.web.domain.AjaxResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping("/api/oss/file")
public class OSSController {
    @Resource
    private FileService fileService;
    /**
     * 文件上传
     * @param file
     * @param module
     * @return
     */
    @PostMapping("/upload")
    public String upload(MultipartFile file, String module) throws IOException {
  //返回上传到oss的路径
        String url = fileService.upload(file,"wy");
        return url;
    }
    @PutMapping("/deleteImage")
    public AjaxResult deleteImage(String url) throws IOException {
        //返回上传到oss的路径
          fileService.deleteFile(url);
        return AjaxResult.success();
    }
}